import {BrowserRouter,Routes,Route,Redirect} from 'react-router-dom'
import Login from '../view/login/login.js'
import Layout from '../view/layout/layout.js'
import Notfound from '../view/notfound/notfound.js'
import ProductList from '../view/pms/product/list/product.js'
import ProductAdd from '../view/pms/product/add/product.js'
import PmsBrandList from '../view/pms/brand/list/list.js';
import PmsCategoryList from '../view/pms/category/list/list.js'
import PmsTypeList from '../view/pms/type/list/list.js'
import Home from '../view/home/home.js'
import Cookies from 'js-cookie'
export default function(){
	
	let routes = <Routes>
			{Cookies.get("mytoken") ? null : <Redirect  to="/login" />}
			<Route path="/login" element={<Login/>}></Route>
			<Route path="/" element={<Layout/>}>
				<Route index element={<Home/>}></Route>
			</Route>
			<Route path="/pms" element={<Layout/>}>
				<Route  path="product" element={<ProductList/>}/>
				<Route  path="addProduct" element={<ProductAdd/>}/>
				<Route  path="brand" element={<PmsBrandList/>}/>
				<Route  path="productCate" element={<PmsCategoryList/>}/>
				<Route  path="productAttr" element={<PmsTypeList/>}/>
			</Route>
			<Route path="/oms" element={<Layout/>}>
				<Route  path="order" element={<ProductList/>}/>
				<Route  path="orderSetting" element={<ProductAdd/>}/>
				<Route  path="returnApply" element={<PmsBrandList/>}/>
				<Route  path="productCate" element={<PmsCategoryList/>}/>
				<Route  path="xiaxie" element={<PmsTypeList/>}/>
			</Route>
			<Route path="/sms" element={<Layout/>}>
				<Route  path="product" element={<ProductList/>}/>
				<Route  path="addProduct" element={<ProductAdd/>}/>
				<Route  path="brand" element={<PmsBrandList/>}/>
				<Route  path="productCate" element={<PmsCategoryList/>}/>
				<Route  path="xiaxie" element={<PmsTypeList/>}/>
			</Route>
			<Route path="/ums" element={<Layout/>}>
				<Route  path="product" element={<ProductList/>}/>
				<Route  path="addProduct" element={<ProductAdd/>}/>
				<Route  path="brand" element={<PmsBrandList/>}/>
				<Route  path="productCate" element={<PmsCategoryList/>}/>
				<Route  path="xiaxie" element={<PmsTypeList/>}/>
			</Route>
			<Route path="*" element={<Notfound/>}></Route>
		</Routes>;
		
	return <BrowserRouter>
		{routes}
	</BrowserRouter>
}